#include<stdio.h>

int main(){
	FILE * fp = fopen("1.txt", "a+");
	if(fp == NULL){
		perror("fopen");
		return 0;
	}
	//1. 从文件读取单个字符
	int ret = fgetc(fp);
	printf("Get File Char= %c\n", ret);
	//2. 从键盘文件读取单个字符
	int ret2 = getchar();
	printf("Get Keyboard Char= %c\n", ret2);

	//1. 往文件写入单个字符  会先换行再写入这个字符
	int wrc = 'w';
	int ret3 = fputc(wrc, fp);
	if(ret3 == -1){
		perror("fputc");
		fclose(fp);
		return 0;
	}
	//2.往屏幕文件写入单个字符
	putchar(wrc);
	fclose(fp);
	return 0;
}
